<!--
 * @Author: your name
 * @Date: 2022-04-06 17:57:26
 * @LastEditTime: 2022-04-07 09:14:00
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\面试题宏任务微任务220406.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>宏任务和微任务</title>
</head>


<body>
  <script>
    setTimeout(function () {
      console.log("setTimeout");
    })
    new Promise(function (resolve) {
      console.log("promise");
      for (var i = 0; i < 10000; i++) {
        if (i === 10) {
          console.log("for");
        }
        if (i === 9999) {
          resolve("resolve");
        }
      }
    }).then(function (val) {
      console.log(val)
    });
    console.log("console");  //promise   for console resolve setTimeout 
  </script>
</body>

</html>